
private void button5_Click(object sender,EventArgs e)
{
SqlConnection conn =new SqlConnection();
conn.ConnectionString =@"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\ASIF\Documents\Visual Studio2010\Projects\connection\connection\conectionDB.mdf;Integrated Security=True;User Instance=True";
conn.Open();
string qry1 = "Select *from Table1 WHERE pass = @pass";
SqlCommand comand =new SqlCommand(qry1,conn);
comand.Parameters.AddWithValue("@pass",this.textBox1.Text);
SqlDataReader sdr =comand.ExecuteReader();
while (sdr.Read())
{
if (sdr.HasRows == true)
{
MessageBox.Show("login Successfull ");
}
}
if (sdr.HasRows ==false)
{
MessageBox.Show("Access Denied ");
}
}